package LuoGu.模拟与高精度.铺地毯;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
//内存超限

public class Main_fail {
    public static void main(String[] args) throws IOException {
        StreamTokenizer st = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        st.nextToken();
        int n = (int) st.nval;
        int [][] temp = new int [7000][7000];
        for(int i=1;i<=n;i++){
            st.nextToken();
            int a = (int) st.nval;
            st.nextToken();
            int b = (int) st.nval;
            st.nextToken();
            int xl = (int) st.nval;
            st.nextToken();
            int yl = (int) st.nval;

            for(int j=b;j<b+yl;j++){
                for(int k=a;k<a+xl;k++){
                    temp[j][k] = i;
                }
            }
        }
        st.nextToken();
        int ansx = (int) st.nval;
        int ansy = (int) st.nval;
        if(temp[ansy][ansx]!=0) System.out.print(temp[ansy][ansx]);
        else System.out.print("-1");
    }
}
